package priv.bestbeat.cloud.api.gateway.configurations.security;

import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.server.WebFilterExchange;
import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler;
import priv.bestbeat.cloud.api.gateway.utils.ReactiveServerHttpUtil;
import reactor.core.publisher.Mono;

/**
 * 用户认证失败处理器
 * @author 张渠钦
 * @date 2022/1/5 16:35
 */
public class UserAuthenticationFailureHandler implements ServerAuthenticationFailureHandler {
    @Override
    public Mono<Void> onAuthenticationFailure(WebFilterExchange webFilterExchange, AuthenticationException exception) {
        ServerHttpResponse serverHttpResponse = webFilterExchange.getExchange().getResponse();
        return ReactiveServerHttpUtil.sendMono(serverHttpResponse,"3");
    }
}
